package com.nhjf.common.util.tools;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

import com.nhjf.common.util.Properties.SysProperties;

public class MonitorRequest {
	public static boolean request() {
		Socket socket = null;  
        try {  
            socket = new Socket(SysProperties.getInstance().get("socketIp"),Integer.parseInt(SysProperties.getInstance().get("socketPort")) );    
            OutputStream netOut = socket.getOutputStream();  
            DataOutputStream doc = new DataOutputStream(netOut);  
            DataInputStream in = new DataInputStream(socket.getInputStream());  
            String res = in.readUTF();     
            doc.close();  
            in.close();  
            return false;
        } catch (UnknownHostException e) {  
           //log
        	LogMessage.logwrite(MonitorRequest.class, e.getMessage());
        	return true;
        } catch (IOException e) { 
        	LogMessage.logwrite(MonitorRequest.class, e.getMessage());
        	return true;
        } finally {  
            if (socket != null) {  
                try {  
                    socket.close();  
                } catch (IOException e) { 
                	LogMessage.logwrite(MonitorRequest.class, e.getMessage());
                	 return true;
                }  
            }  
        }  
	}
}
